public class Phonebook {
	private static final int MAX_SIZE = 100;
	public Person[] phonebook = new Person[MAX_SIZE];

	public void showContact(Person p) {
		for (int i = 0; i < phonebook.length; i++) {
			if (p.equals(phonebook[i])) {
				System.out.println(i + ". " + phonebook[i]);
			}
		}
	}
	
	public Person[] searchByName(String name) {
		Person []result= new Person[MAX_SIZE];
		for (int i = 0; i < phonebook.length; i++) {
			if (phonebook[i].matchByName(name)) {
				result[i]=phonebook[i];
			}
		}
		return result;
	}

	public Person[] searchBySurname(String surname) {
		Person []result= new Person[MAX_SIZE];
		for (int i = 0; i < phonebook.length; i++) {
			if (phonebook[i].matchBySurname(surname)) {
				result[i]=phonebook[i];
			}
		}
		return result;
	}

	public Person[] searchByAge(int age) {
		Person []result= new Person[MAX_SIZE];
		for (int i = 0; i < phonebook.length; i++) {
			if (phonebook[i].matchByAge(age)) {
				result[i]=phonebook[i];
			}
		}
		return result;
	}

	public Person[] searchByPhone(String phone) {
		Person []result= new Person[MAX_SIZE];
		for (int i = 0; i < phonebook.length; i++) {
			if (phonebook[i].matchByPhone(phone)) {
				result[i]=phonebook[i];
			}
		}
		return result;

	}
}